<div>
  <div class="main-title">
    <h2>房产管理</h2>
  </div>
  <div class="main-section">
    <a href="{:url('edit')}" class="btn btn-success">+ 新增</a>
  </div>
  <div class="main-section">
    <form method="post" action="{:url('sort')}" class="j-form">
      <table class="table table-striped table-bordered table-hover">
        <thead>
          <tr>
            <th width="55">序号</th>
            <th>房产名</th>
            <th>详细地址</th>
            <th width='100'>操作</th>
          </tr>
        </thead>
        <tbody>
          {foreach $property as $v}
          <tr>
            <td>
              <input type="text" class="form-control j-sort" maxlength="5" value="{$v.sort}"
                data-name="sort[{$v.id}]" style="height: 25px;font-size: 12px; padding: 0 5px;">
            </td>
            <td>{$v.name}</td>
            <td>{$v.address}</td>
            <td>
              <a href="{:url('edit', ['id' => $v.id])}" style="margin-right: 5px;">编辑</a>
              <a href="{:url('delete', ['id' => $v.id])}" class="j-del">删除</a>
            </td>
          </tr>
          {/foreach}
          {if count($property)==0}
          <tr>
            <td colspan="5" class="text-center">还没添加项目</td>
          </tr>
          {/if}
        </tbody>
      </table>
      <input type="submit" value="改变排序" class="btn btn-primary">
    </form>
  </div>
</div>
<script>
  main.ajaxForm('.j-form', function () {
    main.contentRefresh();
  });
  $('.j-sort').change(function () {
    $(this).attr('name', $(this).attr('data-name'));
  });
  $('.j-del').click(function () {
    if (confirm('您确定要删除此项？')) {
      main.ajaxPost($(this).attr('href'), function () {
        main.contentRefresh();
      });
    }
    return false;
  });
</script>